<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>一个递归运算</title>
</head>
<body>
<div class="box">
  <h2>回来 <span>吧</span>，人类</h2>
  <p>ok</p>
</div>
<footer></footer>
</body>
<script>
  // 使用递归 遍历整个元素树
  function triverse(node) {
    if(node.nodeType == 1 || node.nodeType == 9){
      console.log(node.nodeType+'\t\t'+node.nodeName+'\t\t'+node.nodeValue);
      for(var i=0;i<node.children.length;i++){
        var child = node.children[i];
        triverse(child);
      }
    }
  }
  triverse(document);
</script>
</html>